package jmine.tec.rpc.common.serialization;

import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;

/**
 * Converts object into JSON representations and vice-versa.
 * 
 * @author lundberg
 */
public interface Serializer {

    /**
     * Serializes an object and sends it through the given stream
     * 
     * @param object object to be serialized
     * @return stream that will give it's bytes.
     * @throws IOException IOException
     */
    InputStream serialize(Object object) throws IOException;

    /**
     * Reads the given stream, deserializing the object.
     * 
     * @param stream binary stream containing a serialized object
     * @return deserialized object
     * @throws IOException IOException
     * @throws ParseException ParseException
     */
    Object deserialize(InputStream stream) throws IOException, ParseException;

}
